%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/complex-filter-via-variables"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 8, 11, 12, 21, 42, 43, 13, 15, 16, 28, 32<br />2: PgSelectInlineApply[38]<br />3: PgSelect[10]<br />ᐳ: Access[39]<br />4: PgSelectRows[17]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 39<br /><br />ROOT __Item{1}ᐸ17ᐳ[18]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 19, 39, 18<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[19]<br />1: <br />ᐳ: 20, 40, 41<br />2: PgSelectRows[33]"):::bucket
    Bucket3("Bucket 3 (listItem)<br /><br />ROOT __Item{3}ᐸ33ᐳ[34]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 35<br /><br />ROOT PgSelectSingle{3}ᐸmessagesᐳ[35]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4

    %% plan dependencies
    PgSelect10[["PgSelect[10∈0] ➊<br />ᐸforumsᐳ"]]:::plan
    Object13{{"Object[13∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Lambda15{{"Lambda[15∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[42]"}}:::plan
    ApplyInput16{{"ApplyInput[16∈0] ➊"}}:::plan
    PgSelectInlineApply38["PgSelectInlineApply[38∈0] ➊"]:::plan
    Object13 & Lambda15 & ApplyInput16 & PgSelectInlineApply38 --> PgSelect10
    Access11{{"Access[11∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access12{{"Access[12∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access11 & Access12 --> Object13
    ApplyInput28{{"ApplyInput[28∈0] ➊"}}:::plan
    Lambda32{{"Lambda[32∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[43]"}}:::plan
    ApplyInput28 & Lambda32 --> PgSelectInlineApply38
    Access8{{"Access[8∈0] ➊<br />ᐸ0.forumFilterᐳ"}}:::plan
    __Value0["__Value[0∈0] ➊<br />ᐸvariableValuesᐳ"]:::plan
    __Value0 --> Access8
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access11
    __Value2 --> Access12
    Access8 --> ApplyInput16
    PgSelectRows17[["PgSelectRows[17∈0] ➊"]]:::plan
    PgSelect10 --> PgSelectRows17
    Access21{{"Access[21∈0] ➊<br />ᐸ0.messagesFilterᐳ"}}:::plan
    __Value0 --> Access21
    Access21 --> ApplyInput28
    Access39{{"Access[39∈0] ➊<br />ᐸ10.m.subqueryDetailsFor24ᐳ"}}:::plan
    PgSelect10 --> Access39
    __Item18[/"__Item[18∈1]<br />ᐸ17ᐳ"\]:::itemplan
    PgSelectRows17 ==> __Item18
    PgSelectSingle19{{"PgSelectSingle[19∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item18 --> PgSelectSingle19
    List40{{"List[40∈2]<br />ᐸ39,18ᐳ"}}:::plan
    Access39 & __Item18 --> List40
    PgClassExpression20{{"PgClassExpression[20∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle19 --> PgClassExpression20
    PgSelectRows33[["PgSelectRows[33∈2]"]]:::plan
    Lambda41{{"Lambda[41∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda41 --> PgSelectRows33
    List40 --> Lambda41
    __Item34[/"__Item[34∈3]<br />ᐸ33ᐳ"\]:::itemplan
    PgSelectRows33 ==> __Item34
    PgSelectSingle35{{"PgSelectSingle[35∈3]<br />ᐸmessagesᐳ"}}:::plan
    __Item34 --> PgSelectSingle35
    PgClassExpression36{{"PgClassExpression[36∈4]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle35 --> PgClassExpression36
    PgClassExpression37{{"PgClassExpression[37∈4]<br />ᐸ__messages__.”featured”ᐳ"}}:::plan
    PgClassExpression36 o--o PgClassExpression37

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value0,__Value2,Access8,PgSelect10,Access11,Access12,Object13,Lambda15,ApplyInput16,PgSelectRows17,Access21,ApplyInput28,Lambda32,PgSelectInlineApply38,Access39 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item18,PgSelectSingle19 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression20,PgSelectRows33,List40,Lambda41 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item34,PgSelectSingle35 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression36,PgClassExpression37 bucket4

